package com.hut.oa.model.bean;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.springframework.format.annotation.DateTimeFormat;

import net.minidev.json.annotate.JsonIgnore;

/**
 * 文件管理表
 * @author 郑单单
 *
 */
@Entity
@Table(name="file_manage")
public class FileManage {
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="fm_id",nullable=false)
	private Long id;//文件id	
	
	@Column(name="fm_type",nullable=false)
	private Long type=0l;//类型id
	
	@Column(name="fm_name",nullable=false)
	private String filename;//文件名字
	
	@Column(name="fm_suffix",nullable=false)
	private String suffix;//后缀
	
	@Column(name="fm_permission",nullable=false)
	private String permission;//权限
	
	@Column(name="fm_update_time",nullable=false)	
	private Date updateTime;//更新时间
	
	@Column(name="fm_is_delete",nullable=false)
	private Integer isDelete=0;//是否在回收站

	@Column(name="fm_path",nullable=false)
	private String path ;//文件存储路径
	
	@Column(name="fm_filesize",nullable=false)
	private Long size ;//文件大小
	
	@Column(name="fm_filetype",nullable=false)
	private String filetype;//文件类型
	
	@ManyToOne()
	@JsonIgnore
	@JoinColumn(name="u_id")	
	private User user;//用户id

	@ManyToOne(fetch=FetchType.EAGER)
	@JsonIgnore
	@JoinColumn(name="dir_id")
	private Directory dir;//目录id
	
	@JsonIgnore
	@ManyToMany(cascade=CascadeType.ALL,fetch = FetchType.LAZY)
	@JoinTable(name = "file_user",
    joinColumns = {
            @JoinColumn(name = "fu_file_id")
    }, inverseJoinColumns = {
    @JoinColumn(name = "fu_user_id")
	})
	private List<User> fileuser;
	
	public FileManage() {}

	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}

	public Long getType() {
		return type;
	}

	public void setType(Long type) {
		this.type = type;
	}

	public List<User> getFileuser() {
		return fileuser;
	}

	public void setFileuser(List<User> fileuser) {
		this.fileuser = fileuser;
	}

	public String getFilename() {
		return filename;
	}

	public void setFilename(String filename) {
		this.filename = filename;
	}

	public String getSuffix() {
		return suffix;
	}

	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}

	public String getPermission() {
		return permission;
	}

	public void setPermission(String permission) {
		this.permission = permission;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	
	public Integer getIsDelete() {
		return isDelete;
	}

	public void setIsDelete(Integer isDelete) {
		this.isDelete = isDelete;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Long getSize() {
		return size;
	}

	public void setSize(Long size) {
		this.size = size;
	}

	public String getFiletype() {
		return filetype;
	}

	public void setFiletype(String filetype) {
		this.filetype = filetype;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public Directory getDir() {
		return dir;
	}

	public void setDir(Directory dir) {
		this.dir = dir;
	}

	@Override
	public String toString() {
		return "FileManage [id=" + id + ", type=" + type + ", filename=" + filename + ", suffix=" + suffix
				+ ", permission=" + permission + ", updateTime=" + updateTime + ", isDelete=" + isDelete + ", user="
				+ user + ", dir=" + dir + "]";
	}
	
	
}
